Skip to content

Mock Version Check API responses in core update tests - #342

Draft
swissspidy wants to merge 1 commit into
mainfrom
claude/wordpress-7-1-test-failures-u577i4
Draft

Mock Version Check API responses in core update tests#342
swissspidy wants to merge 1 commit into
mainfrom
claude/wordpress-7-1-test-failures-u577i4

Conversation

@swissspidy

Copy link
Copy Markdown
Member

Summary

This PR updates the core check-update and core update feature tests to mock the WordPress Version Check API responses, replacing dynamic version placeholders with fixed, stable test data.

Key Changes

  • Mock API responses: Added HTTP mocking for https://api.wordpress.org/core/version-check/1.7/ endpoint in three test scenarios to provide consistent, predictable version data
  • Replace dynamic assertions: Converted regex-based assertions using version placeholders (e.g., {WP_VERSION-latest}, {WP_VERSION-5.8-latest}) to exact string matching with hardcoded version numbers
  • Stabilize test output: Changed from pattern matching to exact output verification in CSV format assertions, ensuring tests produce deterministic results regardless of the actual latest WordPress versions available
  • Updated version expectations:
    • core-check-update.feature: Tests now expect versions 5.8.1 (minor) and 6.0 (major)
    • core-update.feature: Tests now expect versions 6.2.11 (minor) and 6.3 (major), and 6.5.10 for locale tests

Implementation Details

The mocked API responses include realistic WordPress release data with proper JSON structure, including download URLs, package information, PHP/MySQL version requirements, and response types (upgrade/autoupdate). This approach ensures tests remain stable and reproducible while still validating the actual update functionality with real packages.

https://claude.ai/code/session_011sevK5u2P9Egf2Vae5QRu6

Three scenarios install WordPress, downgrade core to an older release and
then expect wordpress.org to offer an in-branch (minor) update for it:

* core-check-update.feature "Check for update via Version Check API"
* core-update.feature "Update to the latest minor release"
* core-update.feature "Update WordPress locale when using --minor"

Whether that offer is returned at all is decided per site: the Version
Check API buckets sites by the URL sent in the `wp_install` request header
and only serves the in-branch `autoupdate` offers to some of them. Every
test site is installed at the same URL, so all jobs share one bucket, and
the bucketing is reshuffled with every WordPress release. After the
WordPress 7.1 release that bucket stopped receiving the offers, leaving
`wp core check-update` with only the major update to report and
`wp core update --minor` with nothing to update to, and all Behat jobs
failed on exactly these three scenarios.

Mock the version-check response in those scenarios so they no longer
depend on which bucket the test site lands in. The offered packages are
real, so the updates are still performed against real archives, and the
expected versions are now fixed instead of tracking whatever wordpress.org
currently considers the latest release of a branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011sevK5u2P9Egf2Vae5QRu6
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3f543cf3-04ae-4f38-81e8-f27ded40da8d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added command:core-check-update Related to 'core check-update' command command:core-update Related to 'core update' command scope:testing Related to testing labels Aug 20, 2026
@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:core-check-update Related to 'core check-update' command command:core-update Related to 'core update' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants